﻿@model IEnumerable<WebSimplicity.Data.Blog.ws_Blog_Posts>

@{
    ViewBag.Title = "Index";
    ViewBag.BlogState = "active";
}
<div class="grid_12">
<table class="table">
    <thead><tr>
        <th scope="col"></th>
        <th scope="col">
            Title
        </th>
       <th scope="col">
            Menu Title
        </th>
        <th scope="col">
            Categories
        </th>
        <th scope="col">
            Allow Comments
        </th>
       <th scope="col">
           Last Modified
        </th>
        <th scope="col">
            Published
        </th>
    </tr></thead>
    <tbody>
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.ActionLink("Edit", "edit", new { id=item.PostId }) |
            @Html.ActionLink("Preview", "preview", new { id = item.PostId }) |
            @Html.ActionLink("Delete", "delete", new { id = item.PostId })
        </td>
        <td>
            @item.Title
        </td>
        <td>
            @item.Slug
        </td>
        <td>
           
        </td>
        <td>
           <img src="@Url.Content(string.Format("~/content/icons/{0}.png",(item.AllowComments? "tick" : "cross")))" alt="@item.AllowComments" />
        </td>
        <td>
            @String.Format("{0:g}", item.ModifiedOn)
        </td>
        <td>
           <img src="@Url.Content(string.Format("~/content/icons/{0}.png",(item.Published? "tick" : "cross")))" alt="@item.Published" />
        </td>
    </tr>
}
</tbody>
</table>
</div>
@section breadcrumbs{
    <ul>
        <li>@Html.ActionLink("Blog", "blog")</li>
        <li>@Html.ActionLink("Posts", "posts")</li>
        <li>Main</li>
    </ul>
    <a href="/blog/posts/create" class="button css_right"><span><span>
        <img src="@Url.Content("~/content/icons/plus-circle.png")" width="16" height="16">
        Add New</span></span></a>
}
@section footer{
    <script type="text/javascript">
        $(document).ready(function () {
            if ($(".table").length > 0) $.rloader([
            { type: 'css', src: '@Url.Content("~/content/css/jquery.datatables.css")' },
            { type: 'js', src: '@Url.Content("~/content/js/jquery.dataTables.min.js")', callback: function () {
                $('table').dataTable({
                    "bJQueryUI": true,
                    /*
                    * We set specific options for each columns here. Some columns contain raw data to enable correct sorting, so we convert it for display
                    * http://www.datatables.net/usage/columns
                    */
                    aoColumns: [                    
							{ bSortable: false },
							{ bSortable: true }, 
							{bSortable: true },
							{ bSortable: true }, 
                            { bSortable: true },
							{bSortable: true },
							{ bSortable: true }
						],
                    "sPaginationType": "full_numbers"
                });
            }
            }
        ]);
        });
        function Delete_Page(id) {
            var answer = confirm("Delete selected messages ?")
            if (answer) {
                $.ajax({
                    type: "POST",
                    url: "/admin/deletepage",
                    data: { id: id },
                    success: function () {
                        document.location.href = "/admin/pages";
                    }
                });
            }
            return false;
        }
    </script>
}